//
//  HMHomeFirstModel.m
//  LoveFreshBeen
//
//  Created by huodian on 16/10/16.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "HMHomeFirstModel.h"

@implementation HMHomeFirstModel

+(instancetype)modelWithDict:(NSDictionary*)dict
{
    HMHomeFirstModel* model = [[HMHomeFirstModel alloc]init];
    
    [model setValuesForKeysWithDictionary:dict];
    
    return model;
    
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
    
}
/*
 
 @property(nonatomic,copy)NSString* img;
 
 @property(nonatomic,copy)NSString* name;
 
 @property(nonatomic,copy)NSString* pm_desc;
 
 @property(nonatomic,copy)NSString* specifics;
 
 @property(nonatomic,copy)NSString* partner_price;
 
 @property(nonatomic,copy)NSString* market_price;
 */
-(NSString *)description
{
    

    return [NSString stringWithFormat:@"%@{img = %@,name = %@,pm_desc = %@,specifics = %@,partner_price = %f,market_price = %f,goodsCount = %ld,number = %ld}",[super description],self.img,self.name,self.pm_desc,self.specifics,self.partner_price,self.market_price,self.goodsCount,self.number];

    
}

+(void)downLoadTheMessageFirst:(NSString*)key andFinish:(void (^)(NSArray *))finishBlock andError:(void (^)())errorBlock
{
    NetWorkingTool* tool = [NetWorkingTool shareInstance];
    
    NSDictionary* paramars = tool.params;
    
    //    NSMutableDictionary* dict = [[NSMutableDictionary alloc]init];
    
    [[NetWorkingTool shareInstance] getDatawithParam:key WithUrlString:paramars[key] withSuccessBlock:^(NSDictionary* data) {
        
    
        
        NSMutableArray* modelArray = [[NSMutableArray alloc]init];
        
        NSArray* array = data[@"data"];
        
//        NSArray* focusArray = dictData[key];
        
        
        
        for (NSDictionary* dict in array) {
            
            HMHomeFirstModel* model = [HMHomeFirstModel modelWithDict:dict];
            
            [modelArray addObject:model];
            
            
            
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            
            finishBlock(modelArray);
        });

    } withFailedBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        errorBlock();
        
    } withErrorBlock:^(NSString *message) {
        
        NSLog(@"%@",message);
        
    }];
}
@end
